package com.yvon.maple.service.msg.core.service.impl;

import com.yvon.boot.mybatis.BaseServiceImpl;
import com.yvon.maple.service.msg.core.model.entity.MessageTemplate;
import com.yvon.maple.service.msg.core.mapper.MessageTemplateMapper;
import com.yvon.maple.service.msg.core.service.MessageTemplateService;
import org.springframework.stereotype.Service;

import static com.yvon.maple.constants.SystemConstant.Common.LIMIT_ONE;

/**
 * @author : Yvon
 * @since : 2022-01-05
 */
@Service
public class MessageTemplateServiceImpl extends BaseServiceImpl<MessageTemplate, MessageTemplateMapper> implements MessageTemplateService {

    @Override
    public MessageTemplate getByTypeAndChannel(String messageType, String channelType) {
        return lambdaQuery()
                .eq(MessageTemplate::getChannelType, channelType)
                .eq(MessageTemplate::getMessageType, messageType)
                .last(LIMIT_ONE)
                .one();
    }
}
